package com.hp.fremarker.starter;

import com.hp.fremarker.beans.BeanFactory;
import com.hp.fremarker.core.ClassScanner;
import com.hp.fremarker.web.handler.HandlerManager;
import com.hp.fremarker.web.server.TomcatServer;

import java.util.List;

/**
 * @author dongxing
 **/
public class MiniApplication {

    public static void run(Class<?> clazz, String[] args) {

        System.out.println("---miniapplication!");

        TomcatServer tomcatServer = new TomcatServer(args);
        try {
            tomcatServer.startServer();
            List<Class<?>> classes = ClassScanner.scanClasses(clazz.getPackage().getName());
            classes.forEach(System.out::println);
            HandlerManager.resolveMappingHandler(classes);
            BeanFactory.initBean(classes);
        } catch (Exception e) {
            e.printStackTrace();
        }


    }
}
